﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BCGC.BLL.Helper;
using BCGC.BLL.Forum;

public partial class Admin_Forum_add_post : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        ddlCategory.DataSource = ForumManager.GetAllCategoryTotalListing();
        ddlCategory.DataTextField = "CategoryName";
        ddlCategory.DataValueField = "CategoryID";
        ddlCategory.DataBind();

     }

    protected void imbSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string tag = txtPostTag.Text.Trim();
            int categoryID =Convert.ToInt32(ddlCategory.SelectedItem.Value);
            int userID = Convert.ToInt32(txtUser.Text.Trim());
            string title = txtTitle.Text.Trim();
            string content = Server.HtmlEncode(fckContent.Value.Trim());
            DateTime date = Convert.ToDateTime(txtDate.Text.Trim());
            bool isReply = chkReply.Checked;
            int displayOrder = Convert.ToInt32(txtDisplayOrder.Text.Trim());
            int replyTOID = Convert.ToInt32(txtReplyToID.Text.Trim());


            if (ForumManager.SavePost(tag,categoryID, userID, title, content, date, isReply, displayOrder, replyTOID, chkActive.Checked))
            {
                uccResponse.SetSuccessMessage("Post successfuly saved");
            }
            else
            {
                uccResponse.SetFailMessage("Failed to save Post");
            }
        }
    }
}
